<template>
  <div class="app-container">
    <h2>解决问题</h2>

    <search-box
      :fields="searchFeilds"
      @search="handleSearch"
      @add="handleAdd"
    />


    <SearchResult
      uid="productSolveQuestion"
      ref="searchResult"
      :params="params"
      :ignoreCommand="ignoreCommand"
    >
      <el-table-column label="解决问题名称" align="left">
        <template slot-scope="{row}">
          <span>{{ row.solveQuestionTitle }}</span>
        </template>
      </el-table-column>

      <el-table-column label="产品服务名称" align="center">
        <template slot-scope="{row}">
          <span>{{ row.chineseTitle }}</span>
        </template>
      </el-table-column>

      <el-table-column label="是否启用" align="center">
        <template slot-scope="{row}">
          <span>{{ row.isEnable === 1 ? '是' : '否' }}</span>
        </template>
      </el-table-column>

    </SearchResult>
  </div>
</template>
<script>
import { EventBus } from '@/utils/event-bus';
import waves from '@/directive/waves';
import SearchBox from '@/components/SearchBox';
import SearchResult from '@/components/SearchResult';
import { getProductLevelList, isEnableOptions } from '@/utils/config';

export default {
  name: 'feature',
  components: { SearchBox, SearchResult },
  directives: { waves },
  data() {
    return {
      searchFeilds: [
        { name: 'SolveQuestionTitle', label: '解决问题标题', type: 'text' },
        { name: 'IsEnable', label: '是否启用', type: 'list', options: isEnableOptions }
      ],

      ignoreCommand: ['detail'],
      params: {}
    };
  },
  created() {
    EventBus.$emit('custom-breadcrumb', getProductLevelList(this.$options.name));
  },

  methods: {
    // 搜索
    handleSearch(data) {
      if (data === void 0) data = {};

      this.params = data;
      this.$refs['searchResult'].getData(data);
    },

    // 添加
    handleAdd() {
      this.$refs['searchResult'].handleAdd();
    }
  }
}
</script>
